package cn.neusoft.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class JsonResult<T>{

    private Integer code;
    private String msg;
    private T data;

    public JsonResult(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public JsonResult SUCCESS(T data){
        return new JsonResult(200,"success",data);
    }

    public JsonResult ERROR(){
        return new JsonResult(500,"error");
    }

    public JsonResult ERROR(Integer code,String msg){
        return new JsonResult(code,msg);
    }

    public JsonResult ERROR(String msg){
        return new JsonResult(500,msg);
    }

}
